{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "cf9d8b28-70a4-4bd0-b168-5a97eaded26e",
   "metadata": {},
   "source": [
    "# 作业（2024.10.17）\n",
    "## 在当前数据的基础上，请进一步完成：\n",
    "1. 计算每个学生的平均。\n",
    "2. 计算每门课的平均\n",
    "3. 按学生的总分排序，输出到CSV，文件名自定\n",
    "4. 请给出一个成绩分析报告：\n",
    "    班上每门课的及格率 ，统计各分数的人数（<60%, 60-80%, 80%以上）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "a3c3ad92-2c98-40c9-8a9a-306ba160a8f7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>math</th>\n",
       "      <th>english</th>\n",
       "      <th>physic</th>\n",
       "      <th>chinese</th>\n",
       "      <th>total</th>\n",
       "      <th>average</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>322191001</th>\n",
       "      <td>83</td>\n",
       "      <td>77</td>\n",
       "      <td>70</td>\n",
       "      <td>108</td>\n",
       "      <td>338</td>\n",
       "      <td>84.50</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>322191002</th>\n",
       "      <td>60</td>\n",
       "      <td>45</td>\n",
       "      <td>85</td>\n",
       "      <td>87</td>\n",
       "      <td>277</td>\n",
       "      <td>69.25</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>322191003</th>\n",
       "      <td>92</td>\n",
       "      <td>76</td>\n",
       "      <td>84</td>\n",
       "      <td>101</td>\n",
       "      <td>353</td>\n",
       "      <td>88.25</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>322191004</th>\n",
       "      <td>75</td>\n",
       "      <td>88</td>\n",
       "      <td>67</td>\n",
       "      <td>101</td>\n",
       "      <td>331</td>\n",
       "      <td>82.75</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>322191005</th>\n",
       "      <td>68</td>\n",
       "      <td>61</td>\n",
       "      <td>75</td>\n",
       "      <td>78</td>\n",
       "      <td>282</td>\n",
       "      <td>70.50</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>322191006</th>\n",
       "      <td>44</td>\n",
       "      <td>59</td>\n",
       "      <td>81</td>\n",
       "      <td>108</td>\n",
       "      <td>292</td>\n",
       "      <td>73.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>322191007</th>\n",
       "      <td>81</td>\n",
       "      <td>79</td>\n",
       "      <td>80</td>\n",
       "      <td>99</td>\n",
       "      <td>339</td>\n",
       "      <td>84.75</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>322191008</th>\n",
       "      <td>77</td>\n",
       "      <td>36</td>\n",
       "      <td>74</td>\n",
       "      <td>70</td>\n",
       "      <td>257</td>\n",
       "      <td>64.25</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>322191009</th>\n",
       "      <td>-3</td>\n",
       "      <td>41</td>\n",
       "      <td>70</td>\n",
       "      <td>76</td>\n",
       "      <td>184</td>\n",
       "      <td>46.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>322191010</th>\n",
       "      <td>31</td>\n",
       "      <td>84</td>\n",
       "      <td>92</td>\n",
       "      <td>60</td>\n",
       "      <td>267</td>\n",
       "      <td>66.75</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>322191011</th>\n",
       "      <td>21</td>\n",
       "      <td>64</td>\n",
       "      <td>76</td>\n",
       "      <td>78</td>\n",
       "      <td>239</td>\n",
       "      <td>59.75</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>322191012</th>\n",
       "      <td>32</td>\n",
       "      <td>56</td>\n",
       "      <td>58</td>\n",
       "      <td>90</td>\n",
       "      <td>236</td>\n",
       "      <td>59.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>322191013</th>\n",
       "      <td>37</td>\n",
       "      <td>94</td>\n",
       "      <td>59</td>\n",
       "      <td>78</td>\n",
       "      <td>268</td>\n",
       "      <td>67.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>322191014</th>\n",
       "      <td>60</td>\n",
       "      <td>113</td>\n",
       "      <td>80</td>\n",
       "      <td>81</td>\n",
       "      <td>334</td>\n",
       "      <td>83.50</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>322191015</th>\n",
       "      <td>-4</td>\n",
       "      <td>49</td>\n",
       "      <td>88</td>\n",
       "      <td>68</td>\n",
       "      <td>201</td>\n",
       "      <td>50.25</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>322191016</th>\n",
       "      <td>21</td>\n",
       "      <td>67</td>\n",
       "      <td>83</td>\n",
       "      <td>93</td>\n",
       "      <td>264</td>\n",
       "      <td>66.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>322191017</th>\n",
       "      <td>85</td>\n",
       "      <td>44</td>\n",
       "      <td>91</td>\n",
       "      <td>73</td>\n",
       "      <td>293</td>\n",
       "      <td>73.25</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>322191018</th>\n",
       "      <td>124</td>\n",
       "      <td>92</td>\n",
       "      <td>88</td>\n",
       "      <td>95</td>\n",
       "      <td>399</td>\n",
       "      <td>99.75</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>322191019</th>\n",
       "      <td>72</td>\n",
       "      <td>60</td>\n",
       "      <td>86</td>\n",
       "      <td>84</td>\n",
       "      <td>302</td>\n",
       "      <td>75.50</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>322191020</th>\n",
       "      <td>68</td>\n",
       "      <td>96</td>\n",
       "      <td>71</td>\n",
       "      <td>53</td>\n",
       "      <td>288</td>\n",
       "      <td>72.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>322191021</th>\n",
       "      <td>60</td>\n",
       "      <td>56</td>\n",
       "      <td>73</td>\n",
       "      <td>85</td>\n",
       "      <td>274</td>\n",
       "      <td>68.50</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>322191022</th>\n",
       "      <td>59</td>\n",
       "      <td>68</td>\n",
       "      <td>84</td>\n",
       "      <td>106</td>\n",
       "      <td>317</td>\n",
       "      <td>79.25</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>322191023</th>\n",
       "      <td>52</td>\n",
       "      <td>92</td>\n",
       "      <td>92</td>\n",
       "      <td>86</td>\n",
       "      <td>322</td>\n",
       "      <td>80.50</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>322191024</th>\n",
       "      <td>90</td>\n",
       "      <td>68</td>\n",
       "      <td>73</td>\n",
       "      <td>68</td>\n",
       "      <td>299</td>\n",
       "      <td>74.75</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>322191025</th>\n",
       "      <td>62</td>\n",
       "      <td>48</td>\n",
       "      <td>77</td>\n",
       "      <td>56</td>\n",
       "      <td>243</td>\n",
       "      <td>60.75</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>322191026</th>\n",
       "      <td>114</td>\n",
       "      <td>44</td>\n",
       "      <td>76</td>\n",
       "      <td>92</td>\n",
       "      <td>326</td>\n",
       "      <td>81.50</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>322191027</th>\n",
       "      <td>63</td>\n",
       "      <td>68</td>\n",
       "      <td>106</td>\n",
       "      <td>57</td>\n",
       "      <td>294</td>\n",
       "      <td>73.50</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>322191028</th>\n",
       "      <td>41</td>\n",
       "      <td>66</td>\n",
       "      <td>89</td>\n",
       "      <td>42</td>\n",
       "      <td>238</td>\n",
       "      <td>59.50</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>322191029</th>\n",
       "      <td>21</td>\n",
       "      <td>72</td>\n",
       "      <td>88</td>\n",
       "      <td>101</td>\n",
       "      <td>282</td>\n",
       "      <td>70.50</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>322191030</th>\n",
       "      <td>78</td>\n",
       "      <td>76</td>\n",
       "      <td>82</td>\n",
       "      <td>83</td>\n",
       "      <td>319</td>\n",
       "      <td>79.75</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>322191031</th>\n",
       "      <td>57</td>\n",
       "      <td>126</td>\n",
       "      <td>104</td>\n",
       "      <td>27</td>\n",
       "      <td>314</td>\n",
       "      <td>78.50</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>322191032</th>\n",
       "      <td>59</td>\n",
       "      <td>64</td>\n",
       "      <td>95</td>\n",
       "      <td>75</td>\n",
       "      <td>293</td>\n",
       "      <td>73.25</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>322191033</th>\n",
       "      <td>62</td>\n",
       "      <td>80</td>\n",
       "      <td>70</td>\n",
       "      <td>91</td>\n",
       "      <td>303</td>\n",
       "      <td>75.75</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>322191034</th>\n",
       "      <td>100</td>\n",
       "      <td>56</td>\n",
       "      <td>89</td>\n",
       "      <td>108</td>\n",
       "      <td>353</td>\n",
       "      <td>88.25</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>322191035</th>\n",
       "      <td>120</td>\n",
       "      <td>60</td>\n",
       "      <td>92</td>\n",
       "      <td>65</td>\n",
       "      <td>337</td>\n",
       "      <td>84.25</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>322191036</th>\n",
       "      <td>68</td>\n",
       "      <td>47</td>\n",
       "      <td>65</td>\n",
       "      <td>89</td>\n",
       "      <td>269</td>\n",
       "      <td>67.25</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>322191037</th>\n",
       "      <td>71</td>\n",
       "      <td>56</td>\n",
       "      <td>86</td>\n",
       "      <td>102</td>\n",
       "      <td>315</td>\n",
       "      <td>78.75</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>322191038</th>\n",
       "      <td>91</td>\n",
       "      <td>77</td>\n",
       "      <td>75</td>\n",
       "      <td>85</td>\n",
       "      <td>328</td>\n",
       "      <td>82.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>322191039</th>\n",
       "      <td>69</td>\n",
       "      <td>60</td>\n",
       "      <td>83</td>\n",
       "      <td>66</td>\n",
       "      <td>278</td>\n",
       "      <td>69.50</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>322191040</th>\n",
       "      <td>42</td>\n",
       "      <td>79</td>\n",
       "      <td>73</td>\n",
       "      <td>86</td>\n",
       "      <td>280</td>\n",
       "      <td>70.00</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "           math  english  physic  chinese  total  average\n",
       "322191001    83       77      70      108    338    84.50\n",
       "322191002    60       45      85       87    277    69.25\n",
       "322191003    92       76      84      101    353    88.25\n",
       "322191004    75       88      67      101    331    82.75\n",
       "322191005    68       61      75       78    282    70.50\n",
       "322191006    44       59      81      108    292    73.00\n",
       "322191007    81       79      80       99    339    84.75\n",
       "322191008    77       36      74       70    257    64.25\n",
       "322191009    -3       41      70       76    184    46.00\n",
       "322191010    31       84      92       60    267    66.75\n",
       "322191011    21       64      76       78    239    59.75\n",
       "322191012    32       56      58       90    236    59.00\n",
       "322191013    37       94      59       78    268    67.00\n",
       "322191014    60      113      80       81    334    83.50\n",
       "322191015    -4       49      88       68    201    50.25\n",
       "322191016    21       67      83       93    264    66.00\n",
       "322191017    85       44      91       73    293    73.25\n",
       "322191018   124       92      88       95    399    99.75\n",
       "322191019    72       60      86       84    302    75.50\n",
       "322191020    68       96      71       53    288    72.00\n",
       "322191021    60       56      73       85    274    68.50\n",
       "322191022    59       68      84      106    317    79.25\n",
       "322191023    52       92      92       86    322    80.50\n",
       "322191024    90       68      73       68    299    74.75\n",
       "322191025    62       48      77       56    243    60.75\n",
       "322191026   114       44      76       92    326    81.50\n",
       "322191027    63       68     106       57    294    73.50\n",
       "322191028    41       66      89       42    238    59.50\n",
       "322191029    21       72      88      101    282    70.50\n",
       "322191030    78       76      82       83    319    79.75\n",
       "322191031    57      126     104       27    314    78.50\n",
       "322191032    59       64      95       75    293    73.25\n",
       "322191033    62       80      70       91    303    75.75\n",
       "322191034   100       56      89      108    353    88.25\n",
       "322191035   120       60      92       65    337    84.25\n",
       "322191036    68       47      65       89    269    67.25\n",
       "322191037    71       56      86      102    315    78.75\n",
       "322191038    91       77      75       85    328    82.00\n",
       "322191039    69       60      83       66    278    69.50\n",
       "322191040    42       79      73       86    280    70.00"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "import matplotlib.pyplot as plt\n",
    "\n",
    "StudentID = np.arange(1, 41)+322191000               #学号\n",
    "math = np.random.normal(60,30,40).astype(np.int32)    #数学成绩\n",
    "english = np.random.normal(70,20,40).astype(np.int32) #英语成绩\n",
    "physic = np.random.normal(80,10,40).astype(np.int32)  #物理成绩\n",
    "chinese = np.random.normal(80,20,40).astype(np.int32) #语文成绩\n",
    "total = (math+english+physic+chinese)                 #四科总分\n",
    "average = (total/4)                                   #四科平均\n",
    "data = {'math': math, 'english':english, 'physic':physic, 'chinese':chinese, 'total':total, 'average':average}\n",
    "df = pd.DataFrame(data,index=StudentID)               #输出数据在df里\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "db53ab28-3ebb-496d-bd78-2c19d306e48f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>subject_average</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>数学平均</th>\n",
       "      <td>62.575</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>英语平均</th>\n",
       "      <td>68.600</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>物理平均</th>\n",
       "      <td>80.750</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>语文平均</th>\n",
       "      <td>81.275</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      subject_average\n",
       "数学平均           62.575\n",
       "英语平均           68.600\n",
       "物理平均           80.750\n",
       "语文平均           81.275"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#各科平均分\n",
    "math_average = df['math'].mean()\n",
    "english_average = df['english'].mean()\n",
    "physic_average = df['physic'].mean()\n",
    "chinese_average = df['chinese'].mean()\n",
    "subject_average = np.array([math_average , english_average , physic_average , chinese_average])\n",
    "data_a = {'subject_average':subject_average}\n",
    "index_a = ['数学平均' , '英语平均' ,'物理平均' , '语文平均']\n",
    "df_a = pd.DataFrame(data_a , index_a)\n",
    "df_a"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "44f484f4-1674-491c-b593-e5ed6c2d7054",
   "metadata": {},
   "outputs": [],
   "source": [
    "df_score = df.sort_values(by='total', ascending=False) #将df里面生成的数据按总分从高到低排序，存在df_score里面\n",
    "df_score.to_csv('学生成绩.csv')                         #把df_score输出到csv文件，文件名为 “学生成绩”"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "c8b5e0ec-78e3-40d2-be08-42b133c0c4d4",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "22 24 38 38\n",
      "12 15 15 11\n",
      "10 8 21 21\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Math</th>\n",
       "      <th>English</th>\n",
       "      <th>Physic</th>\n",
       "      <th>Chinese</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>60分以上</th>\n",
       "      <td>22</td>\n",
       "      <td>24</td>\n",
       "      <td>38</td>\n",
       "      <td>38</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>60分--80分</th>\n",
       "      <td>12</td>\n",
       "      <td>15</td>\n",
       "      <td>15</td>\n",
       "      <td>11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>80分以上</th>\n",
       "      <td>10</td>\n",
       "      <td>8</td>\n",
       "      <td>21</td>\n",
       "      <td>21</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          Math  English  Physic  Chinese\n",
       "60分以上       22       24      38       38\n",
       "60分--80分    12       15      15       11\n",
       "80分以上       10        8      21       21"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#成绩在60以上\n",
    "m60 = len(df[df['math']>60])\n",
    "e60 = len(df[df['english']>60])\n",
    "p60 = len(df[df['physic']>60])\n",
    "c60 = len(df[df['physic']>60])\n",
    "print(m60,e60,p60,c60)\n",
    "\n",
    "#成绩在60-80\n",
    "m60_80 = len(df[(df['math']>60)&(df['math']<80)])\n",
    "e60_80 = len(df[(df['english']>60)&(df['english']<80)])\n",
    "p60_80 = len(df[(df['physic']>60)&(df['physic']<80)])\n",
    "c60_80 = len(df[(df['chinese']>60)&(df['chinese']<80)])\n",
    "print(m60_80,e60_80,p60_80,c60_80)\n",
    "\n",
    "#成绩在80以上\n",
    "m80 = len(df[df['math']>80])\n",
    "e80 = len(df[df['english']>80])\n",
    "p80 = len(df[df['physic']>80])\n",
    "c80 = len(df[df['physic']>80])\n",
    "print(m80,e80,p80,c80)\n",
    "\n",
    "Math = np.array([m60,m60_80,m80])\n",
    "English = np.array([e60,e60_80,e80])\n",
    "Physic = np.array([p60,p60_80,p80])\n",
    "Chinese = np.array([c60,c60_80,c80])\n",
    "index_score = ['60分以上' , '60分--80分' , '80分以上']\n",
    "data_s = {'Math':Math , 'English':English , 'Physic':Physic , 'Chinese':Chinese}\n",
    "df_s = pd.DataFrame(data_s , index = index_score)\n",
    "df_s"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "9e17550c-2f48-4831-8c34-305c42c265f7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>math</th>\n",
       "      <th>english</th>\n",
       "      <th>physic</th>\n",
       "      <th>chinese</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>及格率</th>\n",
       "      <td>0.55</td>\n",
       "      <td>0.6</td>\n",
       "      <td>0.95</td>\n",
       "      <td>0.95</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     math  english  physic  chinese\n",
       "及格率  0.55      0.6    0.95     0.95"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#及格率\n",
    "math_pass = np.array(m60/40)\n",
    "english_pass = np.array(e60/40) \n",
    "physic_pass = np.array(p60/40)\n",
    "chinese_pass = np.array(c60/40)\n",
    "\n",
    "data_pass = {'math':math_pass , 'english':english_pass , 'physic':physic_pass , 'chinese':chinese_pass}\n",
    "index_pass = [ \"及格率\"]\n",
    "df_pass = pd.DataFrame(data_pass , index = index_pass)\n",
    "df_pass"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c6d7d3f2-e284-4f75-80ef-f475031251d5",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
